
import BaseComponentByHall from "../../../lib/Base/BaseComponentByHall";

import PagingQueryScrollView from "../../../lib/PagingQueryScrollView";
import ScrollViewSelectItem from "../../../lib/ScrollViewSelectItem";
import ScrollViewToIndex from "../../../lib/ScrollViewToIndex";
import ScrollSelector_item from "./ScrollSelector_item/ScrollSelector_item";


const { ccclass, property } = cc._decorator;

@ccclass
export default class ScrollSelect extends BaseComponentByHall {
    @property(PagingQueryScrollView)
    PagingQuery_sv: PagingQueryScrollView = null;
    @property(ScrollViewToIndex)
    ScrollViewToIndex_sc: ScrollViewToIndex = null;

    @property(ScrollViewSelectItem)
    ScrollViewSelectItem_sc: ScrollViewSelectItem = null;

    @property(cc.ScrollView)
    sv_scrollView: cc.ScrollView = null;
    content: cc.Node = null;


    onLoad() {
        this.content = this.sv_scrollView.content;
    }
    onEnable() {


    }
    onDisable() {


    }
    initData(data: number[], type) {
        if (!data) {
            data = []
        };

        this.PagingQuery_sv.setData(data.length, (node, index) => {
            let item_sc: ScrollSelector_item = node.getComponent(node.name)
            item_sc.initData({
                value: data[index],
                type: type,
            })
        }, undefined, data.length, true)
    }
    scrollToIndex(index = 0, maxIndex = 0, dt = 1) {
        this.ScrollViewToIndex_sc.ScrollToIndex(index, maxIndex, dt)
    }
    getNowSelectItem() {
        return this.ScrollViewSelectItem_sc.check();
    }
}
